﻿<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head lang="en">
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <link rel="icon" href="images/logo.ico" type="image/x-icon">
    <script
            src="js/login_style.js"
            crossorigin="anonymous"
    ></script>
    <link type="text/css" rel="stylesheet" href="${pageContext.request.contextPath}/css/login.css" />
    <script type="text/javascript" src="jquery-3.4.1.js"></script>
    <% String path = request.getContextPath();%>
    <script type="text/javascript">
      function myfun1() {
          /*初始化登录界面要做的工作*/
          $.ajax({
              type:"POST",
              url:"${pageContext.request.contextPath}/login.do",
              data:{method:"getRootMsg"},
              dataType:"json",
              success:function (data) {
                  if (data.haveSession=="yes"){
                      /*登录状态维持*/
                      if (data.from==0 || data.from==1){
                          window.location.href="${pageContext.request.contextPath}/jsp/user.do?method=getLabList&local=introduce&from=user";
                      }else if (data.from==2){
                          window.location.href="${pageContext.request.contextPath}/jsp/user.do?method=getLabList&local=introduce&from=root";
                      }
                  }else {
                      /*设置忘记密码弹窗内容，获取管理员联系方式*/
                      $('.rootMsg').text("账号为学号，初始密码为8个0，若已修改初始密码，请联系管理员："+data.rootMsg+"并提供有效证件（学生证等），查找密码。");

                      let currentPage = sessionStorage.getItem("CurrentPage");
                      /*控制页面处于之前的状态*/
                      if (currentPage == "root") {
                          const container = document.querySelector(".container");
                          container.classList.add("sign-up-mode");
                          sessionStorage.setItem("CurrentPage", "root");
                      }
                  }
              }
          });
          /*初次登录强制跳转逻辑*/
          sessionStorage.setItem("changePwd",true);
      }
        window.onload=myfun1;
    </script>
    <title>实验室资源申请平台</title>
</head>
<body onload="myfun1();">
<%--登录界面--%>
<div class="container">
    <div class="forms-container">
        <div class="signin-signup">
            <form action="${pageContext.request.contextPath }/login.do?local=user" name="actionForm" method="post"
                  class="sign-in-form">
                <img src="images/student.png" alt="">
                <br>
                <h2 class="title">学生教师登录</h2>
                <div class="info">${error}</div>
                <div class="input-field">
                    <i class="fas fa-user"></i>
                    <input type="text" name="userCode" placeholder="Username"/>
                </div>
                <div class="input-field">
                    <i class="fas fa-lock"></i>
                    <input type="password" name="userPassword" placeholder="Password"/>
                </div>
                <button type="submit" class="btn" id="student"><span>登录 </span></button>
                <!--忘记密码-->
                <div class="row">
                    <a href="javascript:void(0)">
                        <div class="title"><span id="addwin">忘记密码? Click here</span></div>
                    </a>
                </div>
            </form>

            <form action="${pageContext.request.contextPath }/login.do?local=root" name="actionForm" method="post"
                  class="sign-up-form">
                <img src="images/root.png" alt="">
                <br>
                <h2 class="title">管理员登录</h2>
                <div class="info">${error2}</div>
                <div class="input-field">
                    <i class="fas fa-user"></i>
                    <input type="text" name="rootCode" placeholder="AdminName"/>
                </div>
                <div class="input-field">
                    <i class="fas fa-lock"></i>
                    <input type="password" name="rootPassword" placeholder="Password"/>
                </div>
                <button type="submit" class="btn" id="root"><span>登录 </span></button>
                <br>
                <br>
                <br>
            </form>

        </div>
    </div>
    <div class="panels-container">
        <div class="panel left-panel">
            <div class="content">
                <h1>实验室资源申请平台</h1>
                <p>
                    Welcome to the laboratory resource application platform of Xi'an University of science and
                    technology
                </p>
                <button class="btn transparent" id="sign-up-btn">
                    管理员
                </button>
            </div>
            <img src="images/student.svg" class="image" alt=""/>
        </div>
        <div class="panel right-panel">
            <div class="content">
                <h1>实验室资源申请平台</h1>
                <p>
                    Welcome to the laboratory resource application platform of Xi'an University of science and
                    technology
                </p>
                <button class="btn transparent" id="sign-in-btn">
                    学生教师
                </button>
            </div>
            <img src="images/root.svg" class="image" alt=""/>
        </div>
    </div>
</div>
<%--弹窗部分--%>
<div id="background" class="shadow"></div>
<div id="float_background" class="box">
    <button id="bubble">
        <img src="images/login_lock.png" style="height: 60%;width: 70%">
    </button>
    <div class="title2">
        <button class="title2_1"></button>
        <span>忘记密码</span>
        <button class="title2_2"></button>
    </div>
    <br>
    <br>
    <div class="right">
        <br>
        <br>
        <div style="padding: 10px; text-align: left;text-indent: 2em;font-size: 15px;margin: 5px;color: rgb(120,120,120)"
             class="rootMsg"></div>
    </div>


    <a href="javascript:void(0)">
        <button id="login_button" class="btn"><span>我知道了</span></button>
    </a>

</div>
</body>
<script type="text/javascript" src="${pageContext.request.contextPath }/js/login.js"></script>
</html>
